package com.example.zheng.qq.view;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;

public class Circle1 {
    public static Bitmap createCircle(Bitmap resouce){
        int length=resouce.getWidth()<resouce.getHeight()? resouce.getWidth():resouce.getHeight();
        Paint paint=new Paint();
        paint.setAntiAlias(true);
        Bitmap target=Bitmap.createBitmap(length,length,Bitmap.Config.ARGB_8888);
        Canvas canvas=new Canvas(target);
        canvas.drawCircle(length/2,length/2,length/2,paint);
        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
        canvas.drawBitmap(resouce,0,0,paint);
        return target;
    }

}
